require 'clear_taobao_title'
require 'dict'
require 'iconv'
#require 'db_help/db_help'
require '../db_help/db_help' 


db_config = {"host" => '118.126.2.138', 'encoding' => 'gbk', 'username' => 'root', 'password' => 'admin', 'database' => 'lady_spider'}

#=begin
db_help = DBHelp::DBHelp.out_initialize(db_config)
items = db_help.query("select num_iid, nick, goods_no, title from spider_items where id>1000 order by id limit 2000" )
items.each_hash do |item|
	begin
		puts "test:#{Iconv.conv('utf-8','gbk', item["title"])}"
	
		test_str = {:title => Iconv.conv('utf-8','gbk', item["title"]), 
							:good_no => Iconv.conv('utf-8','gbk', item["goods_no"]),
							:nick => Iconv.conv('utf-8','gbk', item["nick"]),
							:num_iid => Iconv.conv('utf-8','gbk', item["num_iid"])
							}
		cl = ClearTaobaoTitle.new(test_str)
		cl.filter()
	rescue
		next
	end
end
#=end
=begin
test_str = {:title => "少女蝶五皇冠2010夏装新款韩版牛仔高腰修身雪纺连衣裙C1026B灰",
						:good_no => "C1026B",
						:nick => "少女蝶"
					 }
 
cl = ClearTaobaoTitle.new(test_str)
puts "result:" + cl.filter()
=end
